package com.sali.rbac.repository.impl;

import com.sali.rbac.convert.SysApisConvertDOToModel;
import com.sali.rbac.mapper.SysApisMapper;
import com.sali.rbac.model.SysApisModel;
import com.sali.rbac.orm.SysApisDO;
import com.sali.rbac.repository.ISysApisRepository;
import com.sali.repository.commons.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 权限表 服务实现类
 */
@Service
public class SysApisRepositoryImpl extends BaseServiceImpl<SysApisMapper, SysApisDO> implements ISysApisRepository {

    @Resource
    private SysApisConvertDOToModel sysApisConvertDOToModel;
    @Resource
    private SysApisMapper sysApisMapper;

    /**
     * 根据角色ID查询对应权限
     * @param roleId
     * @return
     */
    @Override
    public List<SysApisModel> findRoleApis(Long roleId){
        List<SysApisDO> roleApis = sysApisMapper.findRoleApis(roleId);
        return sysApisConvertDOToModel.convert(roleApis);
    }
}
